package com.asiainfo.iyoga;

import java.sql.Connection;
import java.sql.SQLException;

public class DriverManager {
	public static final String driver = "com.mysql.jdbc.Driver";
	public static final String url = "jdbc:mysql://127.0.0.1:3306/crebas?useUnicode=true&characterEncoding=UTF-8";
	public static final String user = "root";
	public static final String password = "123";
	
	Connection conn = null;
	
	public Connection getConnection(){
		try {
			try {
				Class.forName(driver);
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			}
			if(conn == null)
			{
				conn = java.sql.DriverManager.getConnection(url, user, password);
			}
		}catch(SQLException ee){
			ee.printStackTrace();
		}
		return conn;	
	}
	
	public static void main(String[] args) {
		DriverManager manager = new DriverManager();
		manager.getConnection();
	}
}
